package com.iuie.ns.frame.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;

public class FileUtils {
	
	public static void fileCopy(File sourceFile, File targetFile) {
		FileInputStream input = null;
		FileOutputStream output = null;
		BufferedReader aReader = null;
		try {
			input = new FileInputStream(sourceFile);
			output = new FileOutputStream(targetFile);
			byte[] inputByte = new byte[8192];
			aReader = new BufferedReader(new FileReader(sourceFile));
			while (input.read(inputByte) != -1) {
				output.write(inputByte);
			}
			output.flush();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (aReader != null)
					aReader.close();
			} catch (IOException e2) {
				e2.printStackTrace();
			}
			try {
				if (input != null)
					input.close();
			} catch (IOException e2) {
				e2.printStackTrace();
			}
			try {
				if (output != null)
					output.close();
			} catch (IOException e2) {
				e2.printStackTrace();
			}
		}
	}

}
